<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<title>layui</title>
	<meta name="renderer" content="webkit">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
	<link rel="stylesheet" href="__static/lib/layui-v2.5.5/css/layui.css" media="all">
	<link rel="stylesheet" href="__static/css/public.css" media="all">
	<style>
		.layui-form-pane .layui-form-label {
			width: 90px;
		}
	</style>
</head>
<body>
<div class="layuimini-container">
	<div class="layuimini-main">

		<!-- <fieldset class="table-search-fieldset">
			<legend>搜索信息</legend>
			<form class="layui-form layui-form-pane" action="">
				<div class="layui-form-item" style="margin-bottom: 5px;">
					<div class="layui-inline">
						<label class="layui-form-label">充值帐户</label>
						<div class="layui-input-inline">
							<input type="text" name="customer" id="customer" autocomplete="off" class="layui-input" placeholder="选择子账户ID">
						</div>
					</div>
					<div class="layui-inline">
						<label class="layui-form-label">充值时间</label>
						<div class="layui-input-inline">
							<input type="text" name="date" id="date" placeholder="选择充值时间" autocomplete="off" class="layui-input">
						</div>
					</div>
					<div class="layui-inline">
						<button type="submit" class="layui-btn layui-btn-primary"  lay-submit lay-filter="data-search-btn"><i class="layui-icon"></i> 搜 索</button>
					</div>
				</div>
			</form>
		</fieldset> -->
		<table class="layui-hide" id="currentTableId" lay-filter="currentTableFilter"></table>

		<script type="text/html" id="currentTableBar">
			<a style="{{d.is_accountant==1?'display:none;':''}}{{d.status==1?'display:none;':''}}" class="layui-btn layui-btn-normal layui-btn-xs data-count-edit" lay-event="edit">审核</a>
			<a style="{{d.is_accountant==1?'':'display:none;'}}{{d.status==1?'display:none;':''}}" class="layui-btn layui-btn-normal layui-btn-xs data-count-edit" lay-event="cashier">出纳</a>
			
		</script>
		<script type="text/html" id="typeTableBar">
			{{d.type==1?'赔付到客户备款':''}}
			{{d.type==2?'赔付到账户':''}}
			{{d.type==3?'赔付到客户':''}}
		</script>
		<script type="text/html" id="statusTableBar">
			{{d.status==0?'审核中':''}}
			{{d.status==1?'完成':''}}
		</script>
	</div>
</div>
<script src="__static/lib/layui-v2.5.5/layui.js" charset="utf-8"></script>
<script src="__static/js/lay-config.js?v=1.0.4" charset="utf-8"></script>
<script>
//会计审核
function get_sh(id){
	layer.open({
        type: 2,
        title:'会计审核',
        area: ['60%', '70%'],
        fixed: false, //不固定
        maxmin: true,
        shadeClose:false,	//点击遮罩后关闭提示框
        scrollbar:false, //- 是否允许浏览器出现滚动
        content: "{:url('audit_paid')}?id="+id 
    });
    //layer.full(index);
}
//出纳
function get_cashier(id){
	layer.open({
        type: 2,
        title:'出纳',
        area: ['60%', '90%'],
        fixed: false, //不固定
        maxmin: true,
        shadeClose:false,	//点击遮罩后关闭提示框
        scrollbar:false, //- 是否允许浏览器出现滚动
        content: "{:url('cashier_paid')}?id="+id 
    });
    //layer.full(index);
}

	var $,form, table
	layui.use(['form', 'table', 'tableSelect', 'laydate'], function () {
		$ = layui.jquery , form = layui.form , table = layui.table
			
		table.render({
			elem: '#currentTableId',
			id:'list_paid',
			url: '{:url("list_paid")}?t=json',
			method : 'post',
			toolbar: true,
			cols: [[
				{ field: 'code', title: '赔付编号', width: 180 },
				{ field: 'type', title: '赔付类型',toolbar: '#typeTableBar', width: 150 },
				{ field: 'channel_name', title: '投放渠道', width: 120 },
				{ field: 'account_name', title: '账户名', width: 100 },
				{ field: 'client_name', title: '客户名称', width: 100 },
				{ field: 'id', title: '返点(客户/服务费/媒体)', width: 180 ,templet:function(d){
					var s = d.channel_rebate == undefined ?0:d.channel_rebate
							return d.rebate+' / '+d.service_pay+' / '+s
						}},
				{ field: 'id', title: '金额', width: 120 ,templet:function(d){
							return d.type == 1 ?d.amount:d.type == 3?d.amount:''
						}},
				{ field: 'currency', title: '帐户币', width: 120 ,templet:function(d){
					return d.type == 2 ?d.currency:''
				}},
				{ field: 'note', title: '备注', width: 200 },
				{ field: 'status', title: '状态',toolbar: '#statusTableBar', width: 100 },
				{ field: 'audit_proof_url', title: '凭证', width: 180 ,templet:function(d){
					return d.audit_proof_url?'<img src="'+d.audit_proof_url+'">':''
				}},
				{ field: 'media_name', title: '媒介', width: 180 },
				{ field: 'operate_name', title: '运营', width: 180 },
				{ field: 'create_time', title: '申请时间', width: 180 },
				{ title: '操作', minWidth: 150, fixed: 'right', toolbar: '#currentTableBar', align: "center" }
			]],
			limit: 30,
			page: true,
			skin: 'line'
		});

	
		table.on('tool(currentTableFilter)', function (obj) {
			var data = obj.data;
			switch (obj.event) {
				case 'edit':
					get_sh(data.id);
				break;
				case 'cashier':
					get_cashier(data.id);
				break;
			}
		});
		//监听行单击事件 查看图片
		table.on('row(currentTableFilter)', function(obj){
			  layer.photos({
				  photos: obj.tr
				  ,anim: 5 //0-6的选择，指定弹出图片动画类型，默认随机（请注意，3.0之前的版本用shift参数）
				});
			});
	});
	//重载数据表
	function get_load(msg){
		table.reload('list_paid', {
			  url: '{:url("list_paid")}?t=json',
			});
		layer.msg(msg, {icon: 6});
	}
</script>

</body>
</html>